import time

from selenium.common import StaleElementReferenceException
from selenium.webdriver.common.by import By

from page.base_page import BasePage


class CompensationNotice(BasePage):
    order_number1 = By.XPATH, "//*[@class = 'el-table__body']/tbody/tr[1]/td[4]/div"
    order_number2 = By.XPATH, "//*[@class = 'el-table__body']/tbody/tr[2]/td[4]/div"
    order_number3 = By.XPATH, "//*[@class = 'el-table__body']/tbody/tr[3]/td[4]/div"

    def get_compensation_order_number(self, n):
        time.sleep(0.5)
        while True:
            try:
                order_number = self.find(By.XPATH, f"//*[@class = 'el-table__body']/tbody/tr[{n}]/td[4]/div").text
                break
            except StaleElementReferenceException:
                pass
        return order_number
